var a = getApp();

Page({
  data: {
    
  },

  bindGetUserInfo: function (o) {
    console.log(o);
    if (o.detail.userInfo) {
      "getUserInfo:ok" == o.detail.errMsg && (wx.showLoading({
        title: "登录中...",
        mask: !0
      }),
      a.getData({
        url: a.api.regUserInfo(),
        method: 'POST',
        data: {
          openid: wx.getStorageSync('openId'),
          wxNickName: o.detail.userInfo.nickName,
          wxHeadimg: o.detail.userInfo.avatarUrl,
          wxCountry: o.detail.userInfo.country,
          wxCity: o.detail.userInfo.city
        },
        ok: function (res) {
          console.log(res)
          if (res.statusCode == 200 && res.errMsg == 'request:ok') {
            if (res.data.code == 1) {
              console.log(res.data.data.wxNickName)
              
              wx.setStorageSync('bizUserInfo', res.data.data)

              // console.log('----------------------1-----------------------------')
              // console.log(o.detail.userInfo.nickName)
              // console.log(o.detail.userInfo.avatarUrl)
              // console.log('----------------------2-----------------------------')
              // if (wx.getStorageSync('sceneID') != '' && wx.getStorageSync('sceneID') != null) {
              //   console.log(1111)
              //   wx.request({ // 分销 扫码注册
              //     url: app.api.scanCode(),
              //     method: 'POST',
              //     data: {
              //       openid: wx.getStorageSync('openId'),
              //       wxHeadimg: o.detail.userInfo.avatarUrl,
              //       wxNickName: o.detail.userInfo.nickName,
              //       pid: Number(wx.getStorageSync('sceneID'))
              //     },
              //     success: function (res) {
              //       console.log(res)
              //     }
              //   })
              // }
              setTimeout(function () {
                wx.navigateBack({});
              }, 1500);
         
            }
          }
        }
      }))
    }

  },
  onLoad: function (o) {
  },
  onReady: function () { },
  onShow: function () { },
  onHide: function () { },
  onUnload: function () { },
  onPullDownRefresh: function () { },
  onReachBottom: function () { },
  onShareAppMessage: function () { }
});